<script type="text/javascript">
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['categoryid'])){
            echo '$("#categoryid option[value=\''.$searchdata['categoryid'].'\']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        ?>

    });
    function searchForm(){
        form1.action.value = 'search';
        document.form1.submit();
    }
    function orderfor(vid){
        form1.action.value = 'search';
        form1.orderby.value = vid;
        document.form1.submit();
    }
</script>
<div class="maintop">
    当前位置：文章管理
    <a href="javascript:;" action="<?=$basepath?>_add?<?=$this->page_url($searchdata['page_current'],$page_url)?>" class="mainFrame button icon-plus">添加</a>
    <a href="javascript:;" action="<?=$basepath?>?<?=$this->page_url($searchdata['page_current'],$page_url)?>" class="mainFrame button">刷新</a>
    <? if(ISDEBUG){ ?>
        <a href="javascript:$('.debuginfo').toggle();" class="button">调试信息</a>
    <? } ?>
    <a action="/cache/update?keys=news_" title="更新缓存" class="mainFrame button icon-undo" href="javascript:;">更新缓存</a>
</div>
<form action="<?=$basepath?>"  id="brandsSearch" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
    <div class="main-search">
        <table width="100%">
            <tr>
                <td align="left">
                    <select ID="categoryid" name="categoryid">
                        <option Value="" selected="selected" >所有分类</option>
                        <?php
                        if($category){
                            foreach($category as $k=>$v){
                                echo '<option value="',$k,'" '.(intval($searchdata['categoryid'])==$k?' selected="selected"':'').'>',$v,'</option>';
                            }
                        }
                        ?>
                    </select>
                    <input type="text" ID="sKey" name="sKey" class="int" />&nbsp;&nbsp;
                    每页：
                    <select id="ps" name="ps">
                        <option value="12" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 12) echo 'selected';?> >12</option>
                        <option value="20" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 20) echo 'selected';?> >20</option>
                        <option value="30" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 30) echo 'selected';?> >30</option>
                        <option value="50" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 50) echo 'selected';?> >50</option>
                        <option value="100" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 100) echo 'selected';?> >100</option>
                    </select>
                    <input type="submit" value="搜索" class="upbutton">
                    <input action="<?=$basepath?>_delete_list" type="button" id="deleteSelectId" value="删除选择" class="upbutton">
                </td>
            </tr>
        </table>
    </div>
    <div id="mainbody">
        <table width="100%" class="tablist" id="list">
            <tr class="trbg"><th width="20"><input id="selectAllid" type="checkbox" value="1" /></th>
                <th width="80">浏览</th><th>标题</th><th width="130">分类</th><th width="40">图片</th><th width="40">链接</th><th width="52">状态</th><th width="50">排序</th><th width="80">日期时间</th><th width="80">操作</th></tr>
            <?php
            foreach ($datas as $vr) {
                ?>
                <tr><td width="20"><input type="checkbox" name="selectValue" value="<?=$vr['id']?>" /></td>
                    <td><?=$vr['reading'] ?></td>
                    <td style="text-align:left"><a href="<?=$this->config['weburl']?>/help/detail?id=<?=$vr['id'] ?>" target="_blank"><?=$vr['title'] ?></a></td>
                    <td><?=str_replace('　- ','',$category[intval($vr['category'])]) ?></td>
                    <td><?=(intval($vr['counticon'])>0 ? $vr['counticon']:'-') ?></td>
                    <td><?=($vr['url']!='#'?'<a href="'.$vr['url'].'" target="_blank"><i class="icon-chrome"></i></a>':'<i class="icon-chrome"></i>') ?></td>
                    <td><a href="<?=$basepath?>_state?id=<?=$vr['id']?><?=str_replace(urlencode('{page}'), $page_current, $page_url)?>" target="ajax" func="loadpage" class="upbutton state<?=$vr['state']?>"><?=$vr['state']?'启用':'禁用' ?></a></td>
                    <td><?=$vr['sort'] ?></td>
                    <td><?=date('m-d H:i',$vr['actiontime']) ?></td>
                    <td>
                        <a action="<?=$basepath?>_delete?id=<?=$vr['id']?>" title="删除" class="mainFrame button icon-trash-2" href="javascript:;"></a>
                        <a action="<?=$basepath?>_edit?id=<?=$vr['id']?>" title="编辑" class="mainFrame button icon-edit" href="javascript:;"></a>
                    </td>
                </tr>
            <? } ?>
        </table>
        <?php require(VIEW.'/page.view.php');?>
    </div>
</form>
<script type="text/javascript">
    function beforeSearchForm(){
        var _key = this.sKey.value;
        if(_key.length<=0){
            //throw '搜索关键字不能为空';
        }
    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['categoryid'])){
            echo '$("#categoryid option[value=\''.$searchdata['categoryid'].'\']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        ?>

    });
</script>